package com.yuda.tools.log.utils;


import com.yuda.tools.log.config.LogConstant;

import javax.servlet.http.HttpServletRequest;
import java.io.File;

public class LogUtil {
	
	public static String getOssAnswerByType(int exam_type) {
		String answerFile = "";
//		if(exam_type == 0) {
//			//激活
//			answerFile = "20171222/active/answer/";
//		}
//		else if(exam_type == 1) {
//			//自动测
//			answerFile = "20171222/autotest/answer/";
//		}
//		else if(exam_type == 2) {
//			answerFile = "20190413/formal/answer/";
//		}
		answerFile = "20210424/formal/answer/";
		return answerFile;
	}
	
	public static String getDownloadPath(HttpServletRequest request) {
		String rootDir = "";
		//TODO
		//String rootDir = _request.getSession().getServletContext().getRealPath("/");
		
		String xiTong = System.getProperty("os.name");
		if(xiTong.toUpperCase().startsWith("WIN") ) {
			rootDir = request.getSession().getServletContext().getRealPath("/");
		}else {
			rootDir = "/home/dbLog/";//linux
		}
		String sepatetor= System.getProperty("file.separator");
		  
		File folder = new File(rootDir+sepatetor+LogConstant.exam_date+sepatetor+"dbLogForDownLoad");
		if(!folder.exists() && !folder.isDirectory()){
			folder.mkdirs();
		}  
		
		String downDir = folder.getAbsolutePath();
		return downDir;
	}

}
